﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using YT.DB;
using YT.Modules;

namespace YT.XH.NOSE
{
    public partial class frmNSSendMsgLog : Form
    {
        public frmNSSendMsgLog()
        {
            InitializeComponent();
        }

        private void FillGrid()
        {
            DBAccess dbcon = new DBAccess(false, false);
            dgvDtl.Con = dbcon.Con;
            string strSQL = @"  select recid,SickName,mobilePhone,message,senddate, 
                                case when (
                                cast ( DATEPART( Hour,senddate ) as varchar(2)) 
                                +':'+ cast( DATEPART (minute,senddate ) as varchar(2))
                                +':'+ cast( DATEPART(second,senddate) as varchar(2))
                                ) ='0:0:0' then '' else 
                                cast ( DATEPART( Hour,senddate ) as varchar(2)) 
                                +':'+ cast( DATEPART (minute,senddate ) as varchar(2))
                                +':'+ cast( DATEPART(second,senddate) as varchar(2))
                                end
                                as SendTime
                                FROM SMSoutbox order by senddate,sendtime";
            dgvDtl.Sql = strSQL;
        }

        private void SetGridHead()
        {
            this.dgvDtl.Columns["SickName"].HeaderText = "用户名";
            this.dgvDtl.Columns["mobilePhone"].HeaderText = "手机号码";
            this.dgvDtl.Columns["message"].HeaderText = "短信内容";
            this.dgvDtl.Columns["senddate"].HeaderText = "发送日期";
            this.dgvDtl.Columns["senddate"].Width = 80;
            this.dgvDtl.Columns["sendtime"].HeaderText = "发送时间";
        }

        private void frmNSSendMsgLog_Load(object sender, EventArgs e)
        {
            this.Text = "短信发送历史记录";
            FillGrid();
            SetGridHead();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
